#include <stdio.h>
#include <netdb.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <arpa/inet.h>

int main(int argc, char *argv[]){

	int i;

	if(argc < 2){
		printf("%s <host name>\n", argv[0]);
		exit(0);
	}

	struct hostent *host = gethostbyname(argv[1]);

	for(i = 0; host->h_aliases[i] !=NULL; i++){
		printf("%s\n", host->h_aliases[i]);
	}

	printf("Address type:%s\n", 
			host->h_addrtype == AF_INET ? "AF_INET":"AF_INET6");

	for(i = 0; host->h_addr_list[i] != NULL; i++){
		printf("IP_address %d:%s\n", 
				i, inet_ntoa(*(struct in_addr *)host->h_addr_list[i]));

	}

	endhostent();
	return 0;
}
